import java.sql.Connection;
import java.sql.SQLException;
import java.util.Collection;

/**
 * Created by aleks_000 on 15.12.13.
 */
public abstract class BaseRepository<T> implements Repository<T> {
    protected final Connection connection;

    protected BaseRepository(Connection connection) throws SQLException {
        if (connection == null) {
            throw new NullPointerException();
        }
        if (connection.isClosed()) {
            throw new SQLException();
        }
        this.connection = connection;
    }

    public abstract T get(int id) throws SQLException;

    public abstract Collection<T> getAll() throws SQLException;

    public abstract T create(T obj) throws SQLException;

    public abstract boolean update(T obj) throws SQLException;

    public abstract boolean delete(T obj) throws SQLException;

    public abstract boolean delete(int id) throws SQLException;
}
